/* Callexpbol.p */
/* Esportazione delle bolletine per l'inserimento Web */
/* Funzioni */
FUNCTION OpenFile
RETURNS LOGICAL
  ( /* parameter-definitions */ 
    INPUT ipcFileName AS CHAR
  ) :
/*------------------------------------------------------------------------------
  Purpose:  Opens a file with it's registered application
    Notes:  Can be used to "Open" anything, from a word document, 
            an excel spreadsheet, a web site. You can even use it to
            send e-mail passing e.g.:
            mailto:wim@inrete.it
------------------------------------------------------------------------------*/
def var tvi_Instance as int no-undo.

   RUN ShellExecuteA (0,
                      "open",
                      ipcFileName,
                      "",
                      "",
                      1,
                      output tvi_Instance).

   IF tvi_Instance LT 32 THEN DO:
      PUBLISH "messaggio" (PROGRAM-NAME(1), 0, SUBSTITUTE("ShellExecuteA: &1", tvi_Instance)).
   END.

   RETURN (tvi_Instance GT 32).

END FUNCTION.

/* Variabili */
DEFINE VARIABLE iProject     AS INTEGER    NO-UNDO.
DEFINE VARIABLE cCustRef     AS CHARACTER  NO-UNDO.
DEFINE VARIABLE iCustRefNr   AS INTEGER    NO-UNDO.
DEFINE VARIABLE cCustRefSub  AS CHARACTER  NO-UNDO.
DEFINE VARIABLE hTTRiepilogo AS HANDLE     NO-UNDO.
DEFINE VARIABLE hTTValore    AS HANDLE     NO-UNDO.
DEFINE VARIABLE cFileName    AS CHARACTER  NO-UNDO.
DEFINE VARIABLE lOpen        AS LOGICAL    NO-UNDO.

ASSIGN
  iProject    = 20 /* Comune Milano Manutenzione 2006 */
  cCustRef    = "Intervento breve"
  iCustRefNr  = 123
  cCustRefSub = ""
  cFileName   = SUBSTITUTE("C:\temp\&1 numero &2.html",
                           cCustRef,
                           iCustRefNr)
.


RUN tm/p/expbol.p
  (INPUT iProject,
   INPUT cCustRef,
   INPUT iCustRefNr,
   INPUT cCustRefSub,
   OUTPUT TABLE-HANDLE hTTRiepilogo,
   OUTPUT TABLE-HANDLE hTTValore).

ASSIGN
   hTTRiepilogo:PRIVATE-DATA = SUBSTITUTE("Titolo=&1",
                                          SUBSTITUTE("&1 numero &2",
                                                     cCustRef,
                                                     iCustRefNr))
.

RUN sy/p/tt2html.p
   (INPUT hTTRiepilogo,
    INPUT "RifInterno,NumeroIntervento,Settore,Ufficio,Richiedente,Procedura,DescrizioneRichiesta,DataRichiesta,DataPresaInCarico,Specialista,TipoIntervento,DataIntervento,DataRegistrazione,DescrizioneIntervento,Specialisti,lEsecuzioneTest,lSupportoMessaInEsercizio,lIstruzioniOperative,lDocumentazione,lCollaudo,DataChiusura,Figure",
    INPUT cFileName).

lOpen = TRUE.
MESSAGE "Aprire Bollettina ?"
   VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO-CANCEL UPDATE lOpen.
IF lOpen = ? THEN
   RETURN.

IF lOpen = TRUE THEN
   OpenFile(cFileName).

RUN sy/win/wbrowsett.w
   (INPUT hTTValore).

PROCEDURE ShellExecuteA EXTERNAL "shell32" :
   define input parameter hwnd as long.
   define input parameter lpOperation as char.
   define input parameter lpFile as char.
   define input parameter lpParameters as char.
   define input parameter lpDirectory as char.
   define input parameter nShowCmd as long.
   define return parameter hInstance as long.
END PROCEDURE. /* ShellExecuteA */

